let {
    getAllInfo
} = require('../controller/homeController');

getAllInfoService = async (req, res) => {
    let { classNumber, studentsNumber, teachersNumber } = await getAllInfo();
    res.json({
        code: 200,
        message: "数据获得成功",
        option: {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                axisTick: {
                    alignWithLabel: true
                },
                data: ['教师数量', '学生数量', '班级数量']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: '数量信息',
                    type: 'bar',
                    barWidth: '60%',
                    data: [teachersNumber, studentsNumber, classNumber],
                }
            ]
        }
    })
}

getGoodTeacherService = (req, res) => {
    res.json({
        code: 200,
        message: "数据获得成功",
        option: {
            tooltip: {
                trigger: 'item'
            },
            legend: {
                bottom: '-2%',
                left: 'center'
            },
            series: [
                {
                    name: '教师好评度',
                    type: 'pie',
                    radius: ['40%', '70%'],
                    avoidLabelOverlap: false,
                    itemStyle: {
                        borderRadius: 10,
                        borderColor: '#fff',
                        borderWidth: 2
                    },
                    label: {
                        show: false,
                        position: 'center'
                    },
                    emphasis: {
                        label: {
                            show: true,
                            fontSize: 40,
                            fontWeight: 'bold'
                        }
                    },
                    labelLine: {
                        show: false
                    },
                    data: [
                        { value: 1048, name: '张三' },
                        { value: 735, name: '李四' },
                        { value: 580, name: '王五' },
                        { value: 484, name: '赵六' }
                    ]
                }
            ]
        }
    })
}

getStudentJiuYe = (req, res) => {
    res.json({
        code: 200,
        message: "数据获得成功",
        option: {
            title : {
                text: '学生就业率统计表',
                left: 'center'
            },
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            xAxis: {
                type: 'category',
                axisTick: {
                    alignWithLabel: true
                },
                data: ['2018', '2019', '2020', '2021', '2022', '2023']
            },
            yAxis: {
                type: 'value'
            },
            series: [
                {
                    name: '就业信息',
                    data: [2021,1756,1532,2112,1888,2312],
                    type: 'line',
                    smooth: true,
                }
            ]
        }
    })
}




module.exports = {
    getAllInfoService,
    getGoodTeacherService,
    getStudentJiuYe
}